#include "mymask.h"
#include <QPainter>

MyMask::MyMask(QString s)
{
    sourcePath = s;
}

//给sourcePath的图案画一个圆形的遮罩
QPixmap MyMask::GetCirclePixMap(int beginX, int beginY, int x, int y){
    QPixmap pixmapa(sourcePath);
    QPixmap pixmap(x, y);
    pixmap.fill(Qt::transparent);

    QPainterPath path;
    path.addEllipse(beginX, beginY, x, y);//添加一个椭圆，起点坐标x=0,y=0,椭圆形的x半径=80,y半径=80，xy相同画出来的就是圆

    QPainter painter(&pixmap);
    painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true);//防锯齿
    painter.setClipPath(path);
    painter.drawPixmap(beginX, beginY, x, y, pixmapa);//
    return pixmap;
}
